package leetcode;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class eleven {
    public static int longestOnes(int[] nums, int k) {
        int count;
        int n=nums.length;
        int max=0;
//        List<Integer> list=new ArrayList<>();
        for(int i=0;i<n;i++){
            count=0;
            for(int j=i;j<n;j++){
                if(nums[j]==0){
                    count++;
                }
                if(count>k){
                    max=Math.max(max,j-i);
                    break;
                }

            }
        }
        return max;

    }

    public static void main(String[] args) {
        int[] array={0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1};
        int i = longestOnes(array, 3);
        System.out.println(i);
    }
}
